package com.codyy.charts.chartsapplication;

import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.codyy.mobile.support.chart.PolyTextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lijian on 2018/3/12.
 */

public class PolyChartActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_poly_chart);
        PolyTextView textView = findViewById(R.id.chart);
        PolyTextView textView2 = findViewById(R.id.chart2);
        PolyTextView textView3 = findViewById(R.id.chart3);
        List<PolyTextView.PolyText> list = new ArrayList<>();
        PolyTextView.PolyText text = new PolyTextView.PolyText(Color.RED, "一年级一年级一年级一年级一年级一年级", "19小时");
        list.add(text);
        text = new PolyTextView.PolyText(Color.BLUE, "二年级", "19小时");
        list.add(text);
        text = new PolyTextView.PolyText(Color.GREEN, "三年级", "19小时");
        list.add(text);
        text = new PolyTextView.PolyText(Color.MAGENTA, "四年级");
        list.add(text);
        textView.setPolyTexts(list);
        list = new ArrayList<>();
        text = new PolyTextView.PolyText(Color.RED, "111", "1", "50.0%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.BLUE, "222", "1", "50.0%");
        list.add(text);
//        text=new PolyTextView.PolyText(Color.GREEN,"三年级2","19小时","10%");
//        list.add(text);
//        text=new PolyTextView.PolyText(Color.MAGENTA,"四年级2","11","10%");
//        list.add(text);
        textView2.setPolyTexts(list);
        setTv3(textView3);
        setTv4((PolyTextView) findViewById(R.id.chart4));
    }

    private void setTv3(PolyTextView textView3) {
        List<PolyTextView.PolyText> list = new ArrayList<>();
        PolyTextView.PolyText text = new PolyTextView.PolyText(Color.parseColor("#59e7c1"), "其他", "209","20%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#05d380"), "数学", "369","38%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#00c341"), "语文", "32","28%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#ff7c24"), "英语","260","25%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#a370ef"), "物理", "209", "20%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#347eff"), "化学", "9", "13%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#23c9f3"), "思想政治", "109", "4%");
        list.add(text);
        textView3.setPolyTexts(list);

    }
    private void setTv4(PolyTextView textView3) {
        List<PolyTextView.PolyText> list = new ArrayList<>();
        PolyTextView.PolyText text = new PolyTextView.PolyText(Color.parseColor("#59e7c1"), "其他", "209","20%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#05d380"), "数学", "369","38%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#00c341"), "语文", "32","28%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#ff7c24"), "英语","260","25%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#a370ef"), "物理", "209", "20%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#347eff"), "化学", "9", "13%");
        list.add(text);
        text = new PolyTextView.PolyText(Color.parseColor("#23c9f3"), "思想政治", "109", "4%");
        list.add(text);
        textView3.setPolyTexts(list);

    }

    private int dp2px(float dip) {
        final float scale = getResources().getDisplayMetrics().density;
        return (int) (dip * scale + 0.5f);
    }


}
